package com.zkyc.framework.website.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zkyc.framework.common.pojo.ColumnData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ColumnDataMapper extends BaseMapper<ColumnData> {
    @Update({"<script>" +
            "update web_column_data set introduce=replace(introduce,#{sourceText}, #{targetText}), title=replace(title,#{sourceText}, #{targetText}) ,original_content=replace(original_content,#{sourceText}, #{targetText}), gmt_updated=CURRENT_TIMESTAMP" +
            " where id in" +
            "    <foreach item='item' index='index' collection='contentIds' open='(' separator=',' close=')'>" +
            "       #{item}" +
            "    </foreach>" +
            "</script>"
    })
    void replaceContent(@Param("sourceText") String sourceText,
                        @Param("targetText") String targetText,
                        @Param("contentIds") List<Integer> contentIds);
}
